Attribute VB_Name = "Project"
'====================================================================================
'Project - Main game-specific global stuff
'====================================================================================
Option Explicit

Public Game As clsGame           'Score, Lives etc, read clsGame.cls
Public Status As clsStatusBars   'The bars that are always on top and bottom
Public Level As New clsLevel     'The level screen
Public GameScreen As IScreen     'The current screen - logo, title, etc _
                                  This object morphs into the class needed.

'--- High Scores --------------------------------------------------------------------
Public HighScores As New clsScoreTable

'--- Enumerations -------------------------------------------------------------------
'Game Mode: This determines what stream of actions to do each frame. Each of these _
            are referred to as a "screen". They're interchangeable classes
Public Enum PM_GAMEMODE
    GM_Logo = 0         'Showing the Camen Design logo
    GM_Title = 1        'Showing the title screen
    GM_Play = 3         'Player is playing the game
    GM_LvlComplete = 4  '"Level Complete" screen
    GM_GameOver = 5     'Game over (after the level's Game Over mode is complete)
    GM_HighScore = 6    'High Score screen
    GM_Exit = 255       'Program is exiting
End Enum
Public GameMode As PM_GAMEMODE

'Screen Mode: Determines at what stage a screen is at, and what actions to take. _
              Not all of these modes are used for all screens
Public Enum PM_SCREENMODE
    SM_Load = 0      'Prepare scene / load graphics etc
    SM_Intro = 1     'In game, load the level and open doors
    SM_Wait = 2      'Waiting for user choice (titlescreen etc)
    SM_Start = 3     'Gameplay about to start (Ready, Set, Go!), (each time you die)
    SM_Play = 4      'Level is in gameplay, move sprites et al
    SM_Pause = 5     'Gameplay is paused (show pause screen)
    SM_Dead = 6      'Pac Mar has died, pause gameplay
    SM_Complete = 7  'Level has been completed
    SM_GameOver = 8  'All lives lost - game over :'(
    SM_Exit = 9      'Screen closing down to switch to another (Titlescreens etc)
    SM_Quit = 10     'Game cancelled
End Enum
Private MyScreenMode As PM_SCREENMODE
Public ModeStep As Long 'Breaks down screen steps into smaller actions

'The difficulty level settings have to be defined here as you cannot define custom _
 types in a Class Module.
Public Type PM_DIFFICULTYSETTINGS
    Title As String         'Title of difficulty level
    MarSpeed As String      'Speed of the player in px/f
    DibSpeed As String      'Speed of Dib in px/f
    ZimSpeed As String      'Speed of Zim in px/f
    KrocSpeed As String     'Speed of Kroc in px/f
    GirSpeed As String      'Speed of Gir in px/f
    TimeLimit As Long       'Level Time Limit, in seconds
    LoveTime As Long        'Length ghosts stay edible, in frames
    PickupInterval As Long  'Number of seconds between pickups appearing
    PickupWaitTime As Long  'How long the pickup appears on screen (in frames)
    PickupTimeout As Long   'How many frames an active pickup lasts for
End Type
Public DiffModes(5) As PM_DIFFICULTYSETTINGS

'To sequence the levels together as the player progresses, a collection of these _
 types describe which maze to show, in which theme, at what difficulty level. _
 See 'clsGame' where the level sequence is loaded in from 'Sequence.dat'
Public Type PM_LEVELSEQUENCE
    LevelFile As String              'The level file to load
    LevelTheme As String             'Which theme applies
    DiffLevel As PM_DIFFICULTYLEVEL  'Which difficulty applies
    Title1 As String
    Title2 As String
End Type
Public LevelSequence() As PM_LEVELSEQUENCE

'GET ScreenMode: Give the current stage of the current screen
'====================================================================================
Public Property Get ScreenMode() As PM_SCREENMODE: ScreenMode = MyScreenMode: End Property

'LET ScreenMode: Whenever the screen mode is changed, the mode step is reset
'====================================================================================
Public Property Let ScreenMode(ByVal Value As PM_SCREENMODE)
    'Remember that the screen mode, is what stage the current screen animation is _
     on and the mode step is what breaks that down into individual animation actions.
    'Whenever `ScreenMode` is changed, `ModeStep` must be reset. See the `Animate` _
     routines in any 'IScreen_*' module for demonstration of this
    Static PreviousValue As PM_SCREENMODE
    If PreviousValue <> Value Then: PreviousValue = Value: ModeStep = 0
    MyScreenMode = Value
End Property

'====================================================================================
'StartLogo: Show the Camen Design intro logo
'====================================================================================
Public Function StartLogo()
    'Create the Camen Design Logo class
    Set GameScreen = New IScreen_Logo
    
    'Tell the drawing and animating routines to handle the Camen Design Logo
    GameMode = GM_Logo
End Function

'====================================================================================
'StartTitleScreen: Show the Pac Mar main title screen
'====================================================================================
Public Function StartTitleScreen()
    'Clear any particles, for when the title screen is presented after something else
    GameMedia.Particles.ClearAll
    
    'Create the TitleScreen class
    Set GameScreen = New IScreen_Title
    
    'Tell the drawing and animating routines to handle the titlescreen
    GameMode = GM_Title
End Function

'====================================================================================
'StartHighScoreScreen: Show the HighScores screen
'====================================================================================
Public Function StartHighScoreScreen(ByVal ViewMode As Boolean)
    'Create the High Scores screen class. We cannot assign `GameScreen` to this _
     new class and then call `.init`, the call has to be made before as _
     `GameScreen` 'implements `IScreen` which has no `.Init` function
    Dim NewScreen As New IScreen_HighScores
    
    NewScreen.Init ViewMode
    Set GameScreen = NewScreen
    Set NewScreen = Nothing
    
    'Tell the drawing and animating routines to handle the level complete screen
    GameMode = GM_HighScore
End Function

'=== END ============================================================================
'This work is licenced under the Creative Commons Attribution 2.5 License
